package com.bionic.banking.core.entity;

import java.io.Serializable;
import java.util.Date;

public class Customer implements Serializable {

    private Integer customerId;
    private String phone;
    private String fax;
    private String email;
    private String firstName;
    private String lastName;
    private String middleName;
    private Boolean gender;
    private Integer age;    
    private Integer userId;
    private Integer addressId;
    private byte[] image;
    private Date createdon;

    public Customer() {
    }

    public Customer(
            String firstName,
            String lastName,
            String middlename,
            Boolean gender,
            Integer age,
            String phone,
            String fax,
            String email,
            //Integer addressId,
            Integer userId) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.middleName = middlename;
        this.gender = gender;
        this.age = age;
        this.phone = phone;
        this.fax = fax;
        this.email = email;
        //this.addressId = addressId;
        this.userId = userId;
    }

    public Customer(
            String firstName,
            String lastName,
            String middlename,
            Boolean gender,
            Integer age,
            String phone,
            String fax,
            String email,
            Integer userId,
            Integer addressId) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.middleName = middlename;
        this.gender = gender;
        this.age = age;
        this.phone = phone;
        this.fax = fax;
        this.email = email;
        this.userId = userId;
        this.addressId = addressId;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getAddressId() {
        return addressId;
    }

    public void setAddressId(Integer addressId) {
        this.addressId = addressId;
    }
    
    public byte[] getImage() {        
        return image;
    }
    
    //http://www.java-forums.org/javaserver-pages-jsp-jstl/60883-display-image-database-jsp-page.html
    public void setImage(byte[] imagebytes) {
        this.image = imagebytes;        
      /*
        File file = new File("portret.jpg");        
        //String path = file.toURI().toURL().getFile();   
        //Image image = ImageIO.read(path); 
        OutputStream toFile = new FileOutputStream(file);
        toFile.write(imagebytes);        
        imgstream.close();
        toFile.close();
      */
    }
    
    public Date getCreatedOn() {
        return createdon;
    }
        
    public void setCreatedOn(Date datecreated) {
        this.createdon = datecreated;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (customerId != null ? customerId.hashCode() : 0);

        final int multiplier = 23;
        if (hash == 0) {
            int code = 133;
            code = multiplier * code + firstName.hashCode();
            code = multiplier * code + lastName.hashCode();
            code = multiplier * code + age.hashCode();
            hash = code;
        }
        return hash;
    }

    @Override
    public boolean equals(Object object) {

        if (!(object instanceof Customer)) {
            return false;
        }
        Customer other = (Customer) object;

        if ((this.customerId != null && other.customerId != null)
                && (this.customerId.equals(other.customerId))
                || (this.firstName != null && this.firstName.equals(other.firstName)
                && (this.lastName != null && this.lastName.equals(other.lastName)
                && this.age.equals(other.age)))) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return firstName + " " + lastName;
    }
}
